<%= page_title "Kubernetes Namespaces" %>

<%= breadcrumb Kubernetes::Namespace %>

<section class="tabs kubernetes-section clearfix">
  <div class="table table-hover table-condensed">
    <table class="table">
      <tr>
        <th>Name</th>
        <th></th>
      </tr>

      <% @kubernetes_namespaces.each do |namespace| %>
        <tr>
          <td>
            <%= namespace.name %>
            <%= additional_info simple_format(namespace.comment) if namespace.comment? %>
          </td>
          <td><%= link_to "Edit", namespace %></td>
        </tr>
      <% end %>
    </table>
  </div>

  <div class="admin-actions">
    <%= paginate @pagy %>

    <div class="pull-right">
      <%= link_to "New", new_kubernetes_namespace_path, class: "btn btn-default" %>
      <%= link_to "Sync All", sync_all_kubernetes_namespaces_path, class: "btn btn-default", data: {method: :post} %>
      <%= link_to "Validate", "#", data: {target: "#validate_dialog"}, class: "btn btn-default toggle" %>
      <div id="validate_dialog" style="display: none">
        <%= form_tag preview_kubernetes_namespaces_path, class: "form-horizontal", method: :get do %>
          <p>Make sure namespace assignment does not change resource names.</p>
          <%= live_select_tag :project_id, options_for_select(Project.pluck(:name, :id)) %>
          <%= submit_tag "Validate", class: "btn btn-primary" %>
        <% end %>
      </div>
  </div>
</section>

